import 'package:intl/intl.dart';

/// 日期工具类
///
/// * @author xbaistack
/// * @source B站/抖音/小红书/公众号（@小白栈记）
class Dates {
  Dates._();

  static String? format(String pattern, DateTime? time) {
    if (time == null) return null;
    return DateFormat(pattern, Intl.getCurrentLocale()).format(time);
  }

  static DateTime? convert(int timestamp, {bool isUtc = false}) {
    return DateTime.fromMicrosecondsSinceEpoch(timestamp, isUtc: isUtc);
  }
}
